﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Linq;
using System.Windows.Forms;
using HFBizDBLib;

namespace HFBizSystemLib
{
    public partial class xfCompany : HFBizFormLib.xfBase
    {
        private DataClassDataContext tdc;

        public xfCompany()
        {
            InitializeComponent();
        }

        private void dbBinding()
        {
            var tci = from p in tdc.CompanyInfor
                      select p;
            textEdit2.DataBindings.Clear();
            textEdit3.DataBindings.Clear();
            textEdit4.DataBindings.Clear();
            textEdit5.DataBindings.Clear();
            textEdit6.DataBindings.Clear();
            textEdit7.DataBindings.Clear();
            textEdit8.DataBindings.Clear();
            memoEdit1.DataBindings.Clear();
            textEdit9.DataBindings.Clear();
            textEdit10.DataBindings.Clear();
            textEdit11.DataBindings.Clear();
            textEdit2.DataBindings.Add("EditValue", tci, "CName");
            textEdit3.DataBindings.Add("EditValue", tci, "Address");
            textEdit4.DataBindings.Add("EditValue", tci, "Legal");
            textEdit5.DataBindings.Add("EditValue", tci, "Tel");
            textEdit6.DataBindings.Add("EditValue", tci, "Fax");
            textEdit7.DataBindings.Add("EditValue", tci, "Email");
            textEdit8.DataBindings.Add("EditValue", tci, "Website");
            memoEdit1.DataBindings.Add("EditValue", tci, "Introduction");
            textEdit9.DataBindings.Add("EditValue", tci, "Bank");
            textEdit10.DataBindings.Add("EditValue", tci, "BName");
            textEdit11.DataBindings.Add("EditValue", tci, "Account");
        }

        private void xfCompany_Load(object sender, EventArgs e)
        {
            tdc = new DataClassDataContext();
            dbBinding();
        }

        private void simpleButton1_Click(object sender, EventArgs e)
        {
            tdc.SubmitChanges();
            dbBinding();
            MessageBox.Show("保存成功！");
        }

        private void simpleButton2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
